package com.zhongge.test;

import com.zhongge.entity.StuConfig;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @ClassName Main
 * @Description TODO
 * @Author zhongge
 * @Version 1.0
 */
public class Main {
    public static void main(String[] args) {
        ApplicationContext applicationContext = new AnnotationConfigApplicationContext(StuConfig.class);
        System.out.println(applicationContext.getBean("stu"));
    }
    public static void main2(String[] args) {
        //通过注解获取IOC容器
        ApplicationContext applicationContext = new AnnotationConfigApplicationContext("com.zhongge.entity");
        //通过IOC容器获取对象
        System.out.println(applicationContext.getBean("user01"));
    }
    public static void main1(String[] args) {
        ApplicationContext applicationContext = new ClassPathXmlApplicationContext("spring-context.xml");
        System.out.println(applicationContext.getBean("address"));
        System.out.println(applicationContext.getBean("student"));
    }
}
